﻿<ComClass(ClsPlane.ClassId, ClsPlane.InterfaceId, ClsPlane.EventsId)> _
Public Class ClsPlane

#Region "COM GUID"
    ' 这些 GUID 提供此类的 COM 标识 
    ' 及其 COM 接口。若更改它们，则现有的
    ' 客户端将不再能访问此类。
    Public Const ClassId As String = "56eceb09-70ea-4ddb-9ad8-62d162c87435"
    Public Const InterfaceId As String = "a60f1be7-61d3-46dc-8899-8d0ae98c6882"
    Public Const EventsId As String = "42a92f5b-23be-450c-b6d5-7594be55a9ae"
#End Region

    ' 可创建的 COM 类必须具有一个不带参数的 Public Sub New() 
    ' 否则， 将不会在 
    ' COM 注册表中注册此类，且无法通过
    ' CreateObject 创建此类。
    Public Sub New()
        MyBase.New()
    End Sub

#Region "字段和属性"

    Private _origalPt As ClsPoint3d
    Public Property Original() As ClsPoint3d
        Get
            Return _origalPt
        End Get
        Set(ByVal value As ClsPoint3d)
            _origalPt = value
        End Set
    End Property

    Private _u As ClsVector3d
    Public Property Uaxis() As ClsVector3d

        Get
            Return _u
        End Get
        Set(ByVal value As ClsVector3d)
            _u = value
        End Set
    End Property

    Private _v As ClsVector3d
    Public Property Vaxis() As ClsVector3d
        Get
            Return _v
        End Get
        Set(ByVal value As ClsVector3d)
            _v = value
        End Set
    End Property

    Private _normal As ClsVector3d
    Public ReadOnly Property Normal As ClsVector3d
        Get
            Return Me.Uaxis.CrossProductWith(Me.Vaxis).UnitVector
        End Get

    End Property

    Public ReadOnly Property XOY As ClsPlane
        Get
            Return New ClsPlane With {
                .Original = New ClsPoint3d() With {.X = 0, .Y = 0, .Z = 0},
                .Uaxis = New ClsVector3d With {.X = 1, .Y = 0, .Z = 0},
                .Vaxis = New ClsVector3d With {.X = 0, .Y = 1, .Z = 0}
                }
        End Get
    End Property
    Public ReadOnly Property YOZ As ClsPlane
        Get
            Return New ClsPlane With {
                .Original = New ClsPoint3d() With {.X = 0, .Y = 0, .Z = 0},
                .Uaxis = New ClsVector3d With {.X = 0, .Y = 1, .Z = 0},
                .Vaxis = New ClsVector3d With {.X = 0, .Y = 0, .Z = 1}
                }
        End Get
    End Property
    Public ReadOnly Property ZOX As ClsPlane
        Get
            Return New ClsPlane With {
                .Original = New ClsPoint3d() With {.X = 0, .Y = 0, .Z = 0},
                .Uaxis = New ClsVector3d With {.X = 0, .Y = 0, .Z = 1},
                .Vaxis = New ClsVector3d With {.X = 1, .Y = 0, .Z = 0}
                }
        End Get
    End Property





#End Region

#Region "构造函数"

    Public Sub CreatorByUVAixs(ori As ClsPoint3d, u As ClsVector3d, v As ClsVector3d)
        Me.Original = ori
        Me.Uaxis = u.UnitVector
        Me.Vaxis = v.UnitVector
    End Sub
    'Public Sub CreatorByUVAixs(ori As ClsPoint3d, normal As ClsVector3d)
    '    Me.Original = ori
    '    Me.Uaxis = normal.
    '    Me.Vaxis = v.UnitVector
    'End Sub

#End Region
End Class


